<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body>
 <?php
        //一:接收前端浏览器地址栏【超链接】传递过来的参数，通过get获取参数
        echo "删除一个商品";
        $id=$_GET['id'];
        //二:把接收的参数插入到数据表中
        //1.连接数据库
        $link=mysqli_connect("localhost", "root", "");//创建数据库的连接
        mysqli_select_db($link, "itcast");//选择要使用数据库
        mysqli_set_charset($link, "utf8");//设置连接的字符编码格式
        //2.操作数据表，写SQL模板
        $sql="DELETE FROM shop_goods WHERE id=$id;";
        $result=  mysqli_query($link, $sql); //mysqli_query 返回结果：如果select返回结果资源,如果delete update insert返回的true或false
        //3.处理结果记录
        if($result){
            echo "<script>alert('删除商品成功！');location.href='goodslist.php'</script>";
        }else{
            echo "<script>alert('删除商品失败！');;location.href='goodslist.php'</script>";
        }
        ?>
    </body>
</html>
